class ForgottenController < ApplicationController
	
	def index
	end
	
	def sendMessage
		if params[:email] == ''
			flash[:notice] = "No email address was entered"
			render :action => :index
			return
		end
		
		to_contact = Contact.find(:first, :conditions => ["email = ?", params[:email]])
		if not to_contact.nil?
			to_user = User.find(:first, :conditions => ["id = ?", to_contact.id])
			to_person = Person.find(:first, :conditions => ["id = ?", to_contact.id])
			MessageMailer.deliver_forgotten(to_user, to_contact, to_person)
		end
		flash[:notice] = "Your request for a forgotten login/password is being processed"
		redirect_to :controller => :login, :action => :index
	end
end
